package com.way.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.util.DisplayMetrics;
import android.view.View;
import cn.itcast.mobilesafe.R;

import com.way.fragment.RecentChatFragment;
import com.way.fragment.SettingsFragment;
import com.way.slidingmenu.BaseSlidingFragmentActivity;
import com.way.slidingmenu.SlidingMenu;


public class MainActivity extends BaseSlidingFragmentActivity {

	private SlidingMenu mSlidingMenu;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		initSlidingMenu();
		setContentView(R.layout.main_center_layout);
		initViews();
	}

	
	/**绝密便签*/
	public void openNotepad(View view){
		startActivity(new Intent(this,cn.hyf.notepad.FileListActivity.class));
	}
	/**星电筒*/
	public void openLighter(View view){
		startActivity(new Intent(this,cn.hyf.view.LighterActivity.class));
	}
	/**机主信息*/
	public void openOwner(View view){
		startActivity(new Intent(this,com.hyf.CnontactOwner.MainActivity.class));
	}
	/**明信片*/
	public void openCardView(View view){
		startActivity(new Intent(this,com.chiemy.cardview.MainActivity.class));
	}
	
	private void initSlidingMenu() {
		DisplayMetrics dm = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(dm);
		int mScreenWidth = dm.widthPixels;// 获取屏幕分辨率宽度
		setBehindContentView(R.layout.main_left_layout);// 设置左菜单
		FragmentTransaction mFragementTransaction = getSupportFragmentManager()
				.beginTransaction();
		Fragment mFrag = new RecentChatFragment();
		//		Fragment mFrag  = null;
		mFragementTransaction.replace(R.id.main_left_fragment, mFrag);
		mFragementTransaction.commit();
		// customize the SlidingMenu
		mSlidingMenu = getSlidingMenu();
		mSlidingMenu.setMode(SlidingMenu.LEFT_RIGHT);// 设置是左滑还是右滑，还是左右都可以滑，我这里左右都可以滑
		mSlidingMenu.setShadowWidth(mScreenWidth / 40);// 设置阴影宽度
		mSlidingMenu.setBehindOffset(mScreenWidth / 8);// 设置菜单宽度
		mSlidingMenu.setFadeDegree(0.35f);// 设置淡入淡出的比例
		mSlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
		mSlidingMenu.setShadowDrawable(R.drawable.shadow_left);// 设置左菜单阴影图片
		mSlidingMenu
				.setSecondaryShadowDrawable(R.drawable.shadow_right);// 设置右菜单阴影图片
		mSlidingMenu.setFadeEnabled(true);// 设置滑动时菜单的是否淡入淡出
		mSlidingMenu.setBehindScrollScale(0.333f);// 设置滑动时拖拽效果
	}

	private void initViews() {
		mSlidingMenu.setSecondaryMenu(R.layout.main_right_layout);
		FragmentTransaction mFragementTransaction = getSupportFragmentManager()
				.beginTransaction();
		Fragment mFrag = new SettingsFragment();
		mFragementTransaction
				.replace(R.id.main_right_fragment, mFrag);
		mFragementTransaction.commit();
	}

}
